#!/usr/bin/env python
# coding: utf-8

# In[1]:


import requests 


# In[5]:


host = 'https://aip.baidubce.com/oauth/2.0/token?'
payload = {
    'grant_type':'client_credentials',
    'client_id':'TxW3zdkweiFSCqY8YXAmt0wU',
    'client_secret':'djV9oT42Kd9jKbv7zDiFVUyS9f3FwEhm'
}
response = requests.get(host,params=payload)
if response:
    print(response.json())


# In[10]:


# encoding:utf-8

import requests
import base64



request_url = "https://aip.baidubce.com/rest/2.0/image-classify/v2/advanced_general"

f = open('本地图片.jpg', 'rb')
img = base64.b64encode(f.read())


payload={
    'access_token':zhichao_AT,
    'image':img,
    'baike_num':5
}

headers = {'content-type': 'application/x-www-form-urlencoded'}
response = requests.post(request_url, data=payload, headers=headers)
if response:
    print (response.json())


# #### 产品总结
# 1.将用户储存在本地的图片进行鉴别后进行判断类型，方便用户在日常生活种对不确定的物品或者地点进行判断，也可做为拍照产品的附加功能进行使用，在用户拍照后，立刻鉴别。

# ##### 课业小结
# 1 非本地图片的鉴别无法确认
# 2 代码大部分为公用，如需要鉴定其他部分请参考https://gitee.com/xzhichao/api_ai_ml/blob/master/week05/week05_CV_%E5%9B%BE%E5%83%8F%E8%AF%86%E5%88%AB.ipynb#https://gitee.com/link?target=https%3A%2F%2Faip.baidubce.com%2Frest%2F2.0%2Fimage-classify%2Fv2%2Fadvanced_general

# In[ ]:




